#include <stdio.h>
#include <algorithm>

using namespace std;

char data[10000000];
int l[10000000], r[10000000], type[10000000];
int n[10000000], p;
int dp;

const int base [] = {
	1, 3, 12, 72, 576, 6912, 96768, 1741824, 34836480, 836075520};
const int limit [] = {
	2, 3, 5, 7, 11, 13, 17 ,19, 23};

bool isDecimal (int l, int r)
{
	if (data[l] == '0' && l != r)
		return false;
	for (int i = l; i <= r; i ++)
		if (data[i] < '0' || data[i] > '9')
			return false;
	long long num = 0;
	for (int i = l; i <= r; i ++)
		num = num * 10 + data[i] - '0';
	if (num >= base[9])
		return false;
	return true;
}

int getDecimal (int l, int r)
{
	int num = 0;
	for (int i = l; i <= r; i ++)
		num = num * 10 + data[i] - '0';
	return num;
}

bool isDiput (int l, int r)
{
	if (data[l] == 'O' && l == r)
		return true;

	int prev = 10;
	int count = 0;

	for (int i = l; i <= r; i ++)
	{
		int dig;
		if (data[i] == 34)
			dig = 8;
		else if (data[i] == 94)
			dig = 7;
		else if (data[i] == 39)
			dig = 6;
		else if (data[i] == 61)
			dig = 5;
		else if (data[i] == 126)
			dig = 4;
		else if (data[i] == 45)
			dig = 3;
		else if (data[i] == 44)
			dig = 2;
		else if (data[i] == 46)
			dig = 1;
		else if (data[i] == 95)
			dig = 0;
		else
			return false;
		if (dig > prev || dig == prev && count == limit[prev])
			return false;
		if (dig < prev)
		{
			prev = dig;
			count = 1;
		}
		else
			count ++;
	}

	return true;
}

int getDiput (int l, int r)
{
	if (data[l] == 'O' && l == r)
		return 0;

	int prev = 10;
	int count = 0;
	int re = 0;

	for (int i = l; i <= r; i ++)
	{
		int dig;
		if (data[i] == 34)
			dig = 8;
		else if (data[i] == 94)
			dig = 7;
		else if (data[i] == 39)
			dig = 6;
		else if (data[i] == 61)
			dig = 5;
		else if (data[i] == 126)
			dig = 4;
		else if (data[i] == 45)
			dig = 3;
		else if (data[i] == 44)
			dig = 2;
		else if (data[i] == 46)
			dig = 1;
		else if (data[i] == 95)
			dig = 0;
		re += base[dig];
	}

	return re;
}

void putDecimal (int j)
{
	printf("%d", n[j]);
}

int ascii[] = {95, 46, 44, 45, 126, 61, 39, 94, 34};

void putDiput (int j)
{
	if (n[j] == 0)
	{
		printf("O");
		return;
	}
	for (int i = 8; i >= 0; i --)
	{
		while (n[j] >= base[i])
		{
			printf("%c", ascii[i]);
			n[j] -= base[i];
		}
	}
}

int main ()
{
	char ch;

	dp = 0;
	while (scanf("%c", &ch) > 0)
		data[dp ++] = ch;

	p = 0;
	for (int i = 0; i < dp; i ++)
	{
		int j;
		for (j = i; j < dp && (isDecimal(i, j) || isDiput(i, j)); j ++)
			;
		j --;
//		printf("i j %d %d\n", i, j);
		if (j >= i)
		{
			l[p] = i;
			r[p] = j;
			if (isDecimal(i, j))
			{
				type[p] = 0;
				n[p] = getDecimal(i,j);
			}
			else
			{
				type[p] = 1;
				n[p] = getDiput(i,j);
			}
			p ++;
			i = j;
		}
	}

/*
	for (int i = 0; i < p; i ++)
		printf("%d\n", n[i]);
*/
	if (p % 2 == 1)
		sort(n, n + p);
	int j = 0;
	for (int i = 0; i < dp; i ++)
		if (j < p && i == l[j])
		{
			if (type[j] == 0)
				putDiput(j);
			else
				putDecimal(j);

			i = r[j];
			j ++;
		}
		else
			printf("%c", data[i]);

	return 0;
}